

import { Button } from '@arco-design/web-react';
import { CardDetail, CardDetailWalletRefundApply } from '../../types';
import { useEffect, useState } from 'react';
import { dictTag, getDict } from '../../utils/utils';
import UrgeRefundDialog from '../../components/urgeRefundDialog';
interface Props {
    info: CardDetail,
    getDetails: () => void
}
const COMMON_REFUND_STATUS = 'common_refund_status';
/** 加急状态 */
const CARD_DETAIL_WALLET_REFUND_APPLY_IS_TAG = 'card_detail_wallet_refund_apply_is_tag';
/** 订单类型 补录 */
const CARD_DETAIL_CONVERT_ORDER_TYPE = 'card_detail_convert_order_type';
export default function InProgress({ info,getDetails}: Props) {
    const status = info?.cardDetailWalletRefundApplies?.[0]?.status || '' // 退款状态
    const isTag = info?.cardDetailWalletRefundApplies?.[0]?.isTag || '' // 是否加急
    const orderStatus = info?.cardDetailConvertOrder?.orderStatus || '' // 订单状态

    // 加急弹窗
    const [urgeRefundDialogShow, seturgeRefundDialogShow] = useState<CardDetailWalletRefundApply>();
    const [dictDatas, setDictDatas] = useState<Record<string, any>>({});
    useEffect(() => {
        async function fetchDictData() {
            const data = await getDict(COMMON_REFUND_STATUS, CARD_DETAIL_WALLET_REFUND_APPLY_IS_TAG, CARD_DETAIL_CONVERT_ORDER_TYPE);
            setDictDatas(data);
        }

        fetchDictData();
    }, []);
    return (

        <div className='p-10 bw-100 bh-100 minh-200 inProgress bg-white'>
            {
                (status || isTag) && <div className="inProgress_item">
                    <div>
                        退款申请 {dictTag(status, dictDatas[COMMON_REFUND_STATUS])}  {dictTag(isTag, dictDatas[CARD_DETAIL_WALLET_REFUND_APPLY_IS_TAG])}
                        {
                            (status === 'pass' || status === 'wait' ) && isTag?.toString() !== '0' &&  <Button type="primary"  status='danger' className={'ml-10'} size='mini' shape="round" onClick={() => seturgeRefundDialogShow(info?.cardDetailWalletRefundApplies?.[0])}>
                            加急
                         </Button>
                        }
                     
                    </div>
                    <div>
                        {/* <IconRight /> */}
                    </div>
                </div>
            }

            {orderStatus && <div className="inProgress_item">

                <div>
                    换卡订单{dictTag(orderStatus, dictDatas[CARD_DETAIL_CONVERT_ORDER_TYPE])}
                </div>
                <div>
                    {/* <IconRight /> */}
                </div>
            </div>}
            {/* <div className="inProgress_item">
                <div>
                    复购订单
                </div>
                <div>
                    <IconRight />
                </div>
            </div> */}
            {!!urgeRefundDialogShow && (
                <UrgeRefundDialog
                record={urgeRefundDialogShow}
                onCancel={(v) => {
                    seturgeRefundDialogShow(undefined);
                    if (v) {
                        getDetails()
                    }
                }}
                />
            )}
        </div>


    );
}

